package lib.bone.admin.config;

import cn.dev33.satoken.interceptor.SaAnnotationInterceptor;
import lib.bone.common.constant.CommonConst;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author : kindear
 * @Date : 2021-11-15
 * @Log : 2021-11-15 取消  AuthenticationInterceptor 注解鉴权拦截，使用sa-token 进行替代
 */
@Configuration
public class WebAppConfig implements WebMvcConfigurer {

//    @Autowired
//    AuthenticationInterceptor authenticationInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        /**
         * 请求鉴权
         */
//        registry.addInterceptor(authenticationInterceptor).addPathPatterns("/**")
//                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**","/doc.html/**","/filepool/**");
        /**
         * SA-TOKEN 鉴权
         */
        registry.addInterceptor(new SaAnnotationInterceptor()).addPathPatterns("/**");
        

    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        //文件映射和访问路径
        //registry.addResourceHandler(CommonConst.FILE_MAP_PATH).addResourceLocations("file:"+CommonConst.FILE_UPLOAD_PATH);
    }
}
